package cn.jxufe.imp;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.jxufe.dao.FarmDAO;
import cn.jxufe.dao.FarmViewDAO;
import cn.jxufe.entity.Farm;
import cn.jxufe.entity.FarmView;
import cn.jxufe.entity.User;
import cn.jxufe.service.FarmService;
import cn.jxufe.service.FarmViewService;

@Service
public class FarmViewImp implements FarmViewService{
	@Autowired
	FarmViewDAO farmViewDAO;

	@Override
	public List<FarmView> list() {
		return farmViewDAO.findAll();
	}

	@Override
	public Farm toFarm(FarmView farmView) {
		Farm farm = new Farm();
		farm.setId(farmView.getId());
		farm.setUserId(farmView.getUserId());
		farm.setSeedId(farmView.getSeedId());
		farm.setLandId(farmView.getLandId());
		farm.setCurStage(farmView.getCurStage());
		farm.setCurStageThroughTime(farmView.getCurStageThroughTime());
		farm.setHarvest(farmView.getHarvest());
		farm.setIsInsect(farmView.getIsInsect());
		farm.setResidueSeason(farmView.getResidueSeason());
		return farm;
	}

	@Override
	public FarmView findByLandIdAndUserId(int landId, int userId) {
		
		return farmViewDAO.findByLandIdAndUserId(landId, userId);
	}

}
